
package dieci.system;

import dieci.database.PersistentObject;
import dieci.utils.Redondeo;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

/**
 *
 * @author DuckSys
 */
public class OrderRawMaterial implements PersistentObject{

    private Date orderRawMaterialDate;
    private long orderRawMaterialId;
    private Set<OrderRawMaterialDetails> details = new HashSet<>();
    private Supplier supplier;
    private double totalOrderRawMaterialAmount;


    public OrderRawMaterial()
    {
    }

    public OrderRawMaterial(Supplier supp, Date orderRawMaterialDate, double amount)
    {
        this.supplier = supp;
        this.orderRawMaterialDate = orderRawMaterialDate;
        this.totalOrderRawMaterialAmount = Redondeo.Redondear(amount,2);
    }
    
    public OrderRawMaterial(Supplier supp, Date orderRawMaterialDate, Set<OrderRawMaterialDetails> details, double amount)
    {
        this(supp, orderRawMaterialDate, amount);
        this.details = details;
    }

    public OrderRawMaterial(long id, Supplier supp, Date orderRawMaterialDate, Set<OrderRawMaterialDetails> details, double amount)
    {
        this(supp, orderRawMaterialDate, amount);
        this.details = details;
        this.orderRawMaterialId = id;
    }
    
        /**
     * Get the value of totalOrderRawMaterialAmount
     *
     * @return the value of totalOrderRawMaterialAmount
     */
    public double getTotalOrderRawMaterialAmount()
    {
        return totalOrderRawMaterialAmount;
    }

    /**
     * Set the value of totalOrderRawMaterialAmount
     *
     * @param totalOrderRawMaterialAmount new value of totalOrderRawMaterialAmount
     */
    public void setTotalOrderRawMaterialAmount(double totalOrderRawMaterialAmount)
    {
        this.totalOrderRawMaterialAmount = Redondeo.Redondear(totalOrderRawMaterialAmount, 2);
    }

    
    /**
     * Get the value of supplierId
     *
     * @return the value of supplierId
     */
    public Supplier getSupplier()
    {
        return supplier;
    }

    /**
     * Set the value of supplierId
     *
     * @param supplierId new value of supplierId
     */
    public void setSupplier(Supplier supplierId)
    {
        this.supplier = supplier;
    }
   
    
    /**
     * Get the value of details
     *
     * @return the value of details
     */
    public Set<OrderRawMaterialDetails> getDetails()
    {
        return details;
    }

    /**
     * Set the value of details
     *
     * @param details new value of details
     */
    public void setDetails(Set<OrderRawMaterialDetails> details)
    {
        this.details = details;
    }


    /**
     * Get the value of orderRawMaterialId
     *
     * @return the value of orderRawMaterialId
     */
    public long getOrderRawMaterialId()
    {
        return orderRawMaterialId;
    }

    /**
     * Set the value of orderRawMaterialId
     *
     * @param orderRawMaterialId new value of orderRawMaterialId
     */
    public void setOrderRawMaterialId(long orderRawMaterialId)
    {
        this.orderRawMaterialId = orderRawMaterialId;
    }

    /**
     * Get the value of orderRawMaterialDate
     *
     * @return the value of orderRawMaterialDate
     */
    public Date getOrderRawMaterialDate()
    {
        return orderRawMaterialDate;
    }

    /**
     * Set the value of orderRawMaterialDate
     *
     * @param orderRawMaterialDate new value of orderRawMaterialDate
     */
    public void setOrderRawMaterialDate(Date orderRawMaterialDate)
    {
        this.orderRawMaterialDate = orderRawMaterialDate;
    }

    @Override
    public String toString(){
        SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyy");
        
        return String.valueOf(orderRawMaterialId)+" - " + supplier.getName()+ " - " + df.format(orderRawMaterialDate);
    }
}
